<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAreasTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('areas', function (Blueprint $table) {
            $table->id();
            $table->unsignedbigInteger('area_id')->comment('地区标识');
            $table->unsignedBigInteger('p_id')->comment('上级id');
            $table->unsignedInteger('user_id')->comment('用户id');
            $table->string('name')->comment('城市名字');
        });
        //运行省市区插入sql
        $installSql=fopen(database_path().'/area.sql','r');
        $content=fread($installSql,filesize(database_path().'/area.sql'));
        \Illuminate\Support\Facades\DB::insert($content);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('areas');
    }
}
